use tabled::{Table, Tabled};

#[derive(Tabled)]
struct Language {
    name: String,
    designed_by: String,
    invented_year: usize,
}

impl Language {
    fn new(name: &str, designed_by: &str, invented_year: usize) -> Self {
        Self {
            name: name.to_string(),
            designed_by: designed_by.to_string(),
            invented_year,
        }
    }
}

fn main() {
    let languages = vec![
        Language::new("C", "Dennis Ritchie", 1972),
        Language::new("Go", "Rob Pike", 2009),
        Language::new("Rust", "Graydon Hoare", 2010),
    ];

    let table = Table::new(languages).to_string();

    println!("{}", table);
}
